const express = require('express')
const app = express();
// const multer = require('multer');
const bodyParser = require('body-parser')
const expressSwagger = require('express-swagger-generator')(app);
const issue = require('./routes/IssueRoute')
const service = require('./routes/ServiceRoute')


// 使用 body-parser 中间
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// app.use(multer()); // for parsing multipart/form-data

let options = {
    swaggerDefinition: {
        info: {
            // description: '接口文档',
            title: '展示系统API',
            version: '1.0.0',
        },
        host: 'localhost:3000',
        basePath: '/v1',
        produces: [
            "application/json",
            "application/xml"
        ],
        schemes: ['http', 'https'],
        securityDefinitions: {
            JWT: {
                type: 'apiKey',
                in: 'header',
                name: 'Authorization',
                description: "",
            }
        }
    },
    basedir: __dirname, //app absolute path
    files: ['./routes/*.js'] //Path to the API handle folder
};
expressSwagger(options)

// app.get('/api-docs')
app.use('/v1', issue)
app.use('/v1', service)

app.listen(3000, ()=>{
  console.log("服务启动了")
});

